import { ElMessageBox, messageType } from "element-plus";
export type UseElMessageBoxType = {
  content: string
  title?:string
  thenCallback?: (...args:any[]) => any | Promise<any>
  catchCallBack?: (...args:any[]) => void
  finallyCallback?: (...args:any[]) => void
  customClass?: string
  confirmButtonText?: string
  cancelButtonText?: string,
  type?: messageType
}
export const useElMessageBox = ({
  content,
  title = '',
  type = 'warning',
  confirmButtonText = '确定',
  cancelButtonText = "取消",
  thenCallback,
  catchCallBack,
  finallyCallback,
  customClass = '',
}: UseElMessageBoxType) => ElMessageBox.confirm(
    content,title,
    {
      confirmButtonText,
      cancelButtonText,
      type: type,
      center: true,
      draggable: true,
      showClose: false,
      customClass: `my-message-box__status ${customClass}`
    }
  )
    .then(() => {
      thenCallback?.()
    })
    .catch(() => {
      catchCallBack?.()
    })
    .finally(() => {
      finallyCallback?.()
    })